package com.chen.senior;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

// 回顾总结线程的创建
public class ThreadNew {

    public static void main(String[] args) throws ExecutionException, InterruptedException {

        // 1
        new MyThread1().start();

        // 2
        MyThread2 myThread2 = new MyThread2();
        new Thread(myThread2).start();

        // 3
        MyThread3 myThread3 = new MyThread3();
        FutureTask<Integer> futureTask = new FutureTask<>(myThread3);
        new Thread(futureTask).start();
        Integer value = futureTask.get();
        System.out.println(value);

    }

}

class MyThread1 extends Thread {
    @Override
    public void run() {
        System.out.println("继承Thread类");
    }
}

class MyThread2 implements Runnable{
    @Override
    public void run() {
        System.out.println("实现Runnable接口");
    }
}

class MyThread3 implements Callable<Integer> {

    @Override
    public Integer call() throws Exception {
        System.out.println("实现Callable接口");
        return 100;
    }
}